﻿<UserControl x:Class="ToDoList.Views.ToDoListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:SampleData="clr-namespace:ToDoList.SampleData" xmlns:Views="clr-namespace:ToDoList.Views"
             xmlns:Converters="clr-namespace:ToDoList.Converters"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:Touch="clr-namespace:Wintellect.Touch;assembly=Wintellect.Touch" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Converters:ToDoListItemToViewModelConverter x:Key="VMConverter"/>
    </UserControl.Resources>
    <Grid d:DataContext="{d:DesignInstance SampleData:DesignToDoListViewModel,IsDesignTimeCreatable=True}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    <ScrollViewer 
        Width="800" VerticalAlignment="Stretch" >
            <i:Interaction.Behaviors>
                <Touch:ScrollViewerTouchScrollBehavior/>
            </i:Interaction.Behaviors>
            <ItemsControl ItemsSource="{Binding Tasks}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel/>                                           
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Views:ToDoListItemView Margin="5"
                        HorizontalAlignment="Left"
                        DataContext="{Binding Converter={StaticResource VMConverter}}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
    </Grid>
</UserControl>
